reducing an equation to a quadratic form